/**
 * 
 */
package com.BaoHua.demo.bean;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;

/**
 * @author bao
 *
 */
@TableName(value="Design")
public class Design{

	@TableField(value="id")
	private int id;
	@TableField(value="comId")
	private int comId;
	@TableField(value="tmpId")
	private int tmpId;
	@TableField(value="backKey")
	private String backKey; // 备份值。空表示当前设计，show表示展示，其他表示某个时间点的备份
	@TableField(value="pageId")
	private int pageId;	
	@TableField(value="posId")
	private int posId;		// 位置ID。1表示头部，2表示正文上部，3表示正文，8表示正文下部， 9表示底部
	@TableField(value="layoutId")
	private int layoutId;	
	@TableField(value="modId")
	private int modId;
	@TableField(value="listOrder")
	private int listOrder;
	@TableField(value="hide")
	private int hide;
	@TableField(value="screenWidth")
	private int screenWidth;
	@TableField(exist=false)
	private int screenHeight;
	
	public static final String BACK_DESIGN = "";
	public static final String BACK_SHOW = "show";
	public static final int PAGE_COMMON = 0;
	public static final int PAGE_HOME = 1;
	public static final int PAGE_INNER = 2;
	public static final int POSITION_HEADER = 1;
	public static final int POSITION_CONTENT_UP = 2;
	public static final int POSITION_CONTENT = 3;
	public static final int POSITION_CONTENT_DOWN = 8;
	public static final int POSITION_FOOTER = 9;
	
	public static final int LAYOUT_ONE = 1;
	public static final int LAYOUT_L1R2 = 2;
	public static final int LAYOUT_L1R2_L = 21;
	public static final int LAYOUT_L1R2_R = 22;
	public static final int LAYOUT_L2R1 = 3;
	public static final int LAYOUT_L2R1_L = 31;
	public static final int LAYOUT_L2R1_R = 32;
	public static final int LAYOUT_THREE = 4;
	public static final int LAYOUT_THREE_L = 41;
	public static final int LAYOUT_THREE_C = 42;
	public static final int LAYOUT_THREE_R = 43;
	
	/** 三等分 **/
	public static final int LAYOUT_THREE_1 = 44;
	public static final int LAYOUT_THREE_2 = 45;
	public static final int LAYOUT_THREE_3 = 46;
	
	/** 四等分 **/
	public static final int LAYOUT_FOUR = 5;
	public static final int LAYOUT_FOUR_1 = 51;
	public static final int LAYOUT_FOUR_2 = 52;
	public static final int LAYOUT_FOUR_3 = 53;
	public static final int LAYOUT_FOUR_4 = 54;
	
	public String getPreviewImg(){
		return "/css/banner/style-" + tmpId + "/images/banner/preview.jpg";
	}
	
	public String getBackKeySub(){
		if(BACK_DESIGN.equals(backKey) || BACK_SHOW.equals(backKey)){
			return "";
		}
		
		return backKey.split("_")[0];
	}
	
	/**
	 * 1表示适合版式1、22、31、42 （大块）
	 * 2表示适合版式21、32、41、43、44、45、46、51、52、53、54（小块）
	 */
	public int getLayoutType() {
		if(layoutId == Design.LAYOUT_ONE 
				|| layoutId == Design.LAYOUT_L1R2_R
				|| layoutId == Design.LAYOUT_L2R1_L
				|| layoutId == Design.LAYOUT_THREE_C){
			return 1;
		}

		return 2;
	}
	
	/**
	 * 是否显示移动按钮
	 * @return
	 */
	public boolean isShowMove(boolean addMode){
		if(posId == POSITION_HEADER || posId == POSITION_FOOTER){
			return addMode;
		}else{
			return pageId > 0;
		}
	}
	
	/**
	 * 是否显示设置按钮
	 * @return
	 */
	public boolean isShowSet(boolean addMode){
		return !addMode && modId != 15 && modId != 20;
	}

	public boolean isShowAdd(boolean addMode){
		if(posId == POSITION_HEADER || posId == POSITION_FOOTER){
			return addMode;
		}else{
			return true;
		}
	}

	public boolean isShowDel(boolean addMode){
		if(posId == POSITION_HEADER || posId == POSITION_FOOTER){
			return addMode;
		}else{
			return addMode || pageId > 0;
		}
	}

	public boolean isShowFix(boolean addMode){
		return addMode;
	}

	public int getId() {
		return id;
	}

	public int getComId() {
		return comId;
	}

	public int getTmpId() {
		return tmpId;
	}

	public String getBackKey() {
		return backKey;
	}

	public int getPageId() {
		return pageId;
	}

	public int getPosId() {
		return posId;
	}

	public int getModId() {
		return modId;
	}

	public int getListOrder() {
		return listOrder;
	}

	public void setId(int id) {
		this.id = id;
	}

	public void setComId(int comId) {
		this.comId = comId;
	}

	public void setTmpId(int tmpId) {
		this.tmpId = tmpId;
	}

	public void setBackKey(String backKey) {
		this.backKey = backKey;
	}

	public void setPageId(int pageId) {
		this.pageId = pageId;
	}

	public void setPosId(int posId) {
		this.posId = posId;
	}

	public void setModId(int modId) {
		this.modId = modId;
	}

	public void setListOrder(int listOrder) {
		this.listOrder = listOrder;
	}

	public int getScreenWidth() {
		return screenWidth;
	}

	public void setScreenWidth(int screenWidth) {
		this.screenWidth = screenWidth;
	}

	public int getLayoutId() {
		return layoutId;
	}

	public void setLayoutId(int layoutId) {
		this.layoutId = layoutId;
	}

	public int getHide() {
		return hide;
	}

	public void setHide(int hide) {
		this.hide = hide;
	}

	public int getScreenHeight() {
		return screenHeight;
	}

	public void setScreenHeight(int screenHeight) {
		this.screenHeight = screenHeight;
	}

	@Override
	public String toString() {
		return "Design [id=" + id + ", comId=" + comId + ", tmpId=" + tmpId + ", backKey=" + backKey + ", pageId=" + pageId + ", posId=" + posId + ", layoutId=" + layoutId + ", modId=" + modId
				+ ", listOrder=" + listOrder + ", hide=" + hide + ", screenWidth=" + screenWidth + ", screenHeight=" + screenHeight + "]";
	}

}
